from crypt import methods

from flask import Flask, render_template
from werkzeug.routing import BaseConverter

app = Flask(__name__)

class PHoneConverter(BaseConverter):
    regex = r'1[34578]\d{9}'

app.url_map.converters['phone'] = PHoneConverter

@app.route('/phone/<phone:phone>')
def phone(phone):
    return f'phone:{phone}'

# #方式一
# app.config['SECRET_KEY'] = 'secret!'
#app.config['SQLALCHRMY_DATABASE_URL']=''
# app.config['DEBUG'] = True
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
#
# #方式二
# app.config.update(
#     MAIL_SERVER='smtp.gmail.com',
#     MAIL_PORT=465,
#     MAIL_USE_SSL=True,
#     MAIL_USERNAME='',
#     MAIL_PASSWORD='',
#     MAIL_DEFAULT_SENDER=''
# )
#
# #方式三
# app.config.from_file('config.json', load=json.load())


@app.route('/hello1/<num>',methods=['GET'])
@app.route('/hello2')
def hello_world(num):  # put application's code here
    return 'Hello World!'+num


@app.get('/index')
def index():
  name= 'Hello'
  return render_template('index.html', name=name)



@app.route('/user/list')
def user_index():
  name= 'Hello'
  return render_template('index.html', name=name)


@app.route('/dept/list')
def dept_index():
  name= 'Hello'
  return render_template('index.html', name=name)


if __name__ == '__main__':
    app.run()
    print("Hello World")
